As you run the model, you will see the parts passing along the Line to PreTest. To count the parts entering the Line, we will insert a sensor at the start of the Line and, using a Method, instruct the model to increase a counter whenever a part passes the sensor.
Methods are used to write programming code to define special behavior which can not be defined by dialog settings. Plant Simulation provides a programming language named SimTalk for that purpose.
Insert a Variable from the tab Information Flow in the Toolbox above the Line object.
Double-click the variable and change the name to NumberDevices. Check the checkbox Initial Value and enter the value 0. This way the value of the variable is set to zero automatically at the beginning of the simulation.

On the tab Display, set the Font size to Large.
Insert a Method
from the tab Information Flow in the Toolbox below the object Line.
Right-click the Method and rename it to Counter.
Open the dialog window of the Line.
Click the tab Controls.
Click Sensors.
Click New.
Click the button next to Control, select Counter and then click OK.

Close the Sensors dialog.
Click OK again to apply your changes and to close the dialog window of the Line.
Double-click the method Counter.
Copy/paste the following code (select the text then right-click to copy it):
(sensorID : integer)
is
do
NumberDevices := NumberDevices + 1;
end;
Apply the source code with the button
and then close the method window.